import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { environment } from '@env/environment';
import { STChange, STClickRowClassNameType, STColumn, STComponent, STPage } from '@delon/abc/st';
import { DragModalService } from '../../../../../shared/utils/drag-modal.service';
import { TallyManageUnlockService } from '../tally-manage-unlock.service';

@Component({
  selector: 'app-bill-change-shift-list',
  templateUrl: './bill-change-shift.component.html',
  styleUrls: ['./bill-change-shift.component.less']
})
export class BillChangeShiftComponent implements OnInit {
	@Input()
	transportBillId: any;
	pageInfo = {
		total: 0,
		current: 1,
		size: 20,
		loading: false,
		nzPageSizeOptions: environment.nzPageSizeOptions
	};
	pageSetting: STPage = {
		total: '',
		show: true,
		showSize: true,
		front: false,
		pageSizes: environment.nzPageSizeOptions
	};
	@ViewChild('st', { static: false }) private st!: STComponent;
	columns: STColumn[] = [
		{
			title: '序号',
			width: 50,
			index: 'index',
			type: 'no',
			noIndex: (item, col, index) => index + 1 + (this.st.pi - 1) * this.st.ps,
			fixed: 'left',
			className: 'tc'
		},
		{
			title: '时间',
			index: 'createTime',
			width: 120
		},
		{
			title: '理货员',
			index: 'createUserName',
			width: 60
		},
		{
			title: '内容',
			index: 'remark',
			width: 300
		}
	];
	dataList = [];
	constructor(
		private tallyManageUnlockService: TallyManageUnlockService
	) {
	}

	ngOnInit(): void {
		this.loadData();
	}

	loadData(): any {
		const params = {
			transportBillId: this.transportBillId,
			size: this.pageInfo.size,
			current: this.pageInfo.current
		};

		this.pageInfo.loading = true;
		this.tallyManageUnlockService.remarkPage(params).subscribe((res: any) => {
			this.dataList = res.records;
			this.pageInfo.total = res.total;
			this.pageSetting.total = res.total;
			this.pageInfo.loading = false;
		});
	}


	stChange(ret: STChange) {
		if (ret.type === 'pi' || ret.type === 'ps') {
			this.pageInfo.current = ret.pi;
			this.pageInfo.size = ret.ps;
			this.loadData();
		}
	}

	sa: STClickRowClassNameType = {
		fn(record: any, index: number): string {
			return 'selected-row';
		},
		exclusive: true
	};

}
